package io.renren.modules.user.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import io.renren.modules.generator.entity.TTrainingEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.user.entity.TPeopleLogEntity;
import io.renren.modules.user.service.TPeopleLogService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 人员操作表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-07 15:05:46
 */
@RestController
@RequestMapping("/tpeoplelog")
public class TPeopleLogController {
    @Autowired
    private TPeopleLogService tPeopleLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:tpeoplelog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tPeopleLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:tpeoplelog:info")
    public R info(@PathVariable("id") Integer id){
		TPeopleLogEntity tPeopleLog = tPeopleLogService.getById(id);

        return R.ok().put("tPeopleLog", tPeopleLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:tpeoplelog:save")
    public R save(@RequestBody TPeopleLogEntity tPeopleLog){
		tPeopleLogService.save(tPeopleLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:tpeoplelog:update")
    public R update(@RequestBody TPeopleLogEntity tPeopleLog){
		tPeopleLogService.updateById(tPeopleLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:tpeoplelog:delete")
    public R delete(@RequestBody Integer[] ids){
		tPeopleLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 列表
     */
    @RequestMapping("/peopleLog")
    //@RequiresPermissions("generator:tpeoplelog:peopleLog")
    public R peopleLog(@RequestBody TPeopleLogEntity tPeopleLog){
        Map<String,Object> params=new HashMap<String,Object>();
        params.put("page",tPeopleLog.getPage());
        params.put("limit",tPeopleLog.getLimit());
        PageUtils page = tPeopleLogService.peopleLog(params);
        return R.ok().put("page", page);

    }

}
